// 导入组件
import Vue from 'vue';
import Router from 'vue-router';
// 登录
import login from '@/views/login';
// 首页
import index from '@/views/index';

import error from "@/components/error"
/**
 * 基础菜单
 */
// 商品管理
import Goods from '@/views/basic/Goods';

// 仓库管理
import Warehouse from '@/views/basic/Warehouse';

// 仓库人员管理
import Admin from '@/views/basic/Admin';
// 客户管理
import Customer from '@/views/basic/Customer';

// 供应商管理
import Supplier from '@/views/basic/Supplier';

// 入库管理
import Warehousing from '@/views/basic/Warehousing';

// 出库管理
import Delivery from '@/views/basic/Delivery';

// 首页
import Dashbord from '@/views/basic/Dashbord';



/**
 * 系统管理
 */
// 用户管理
import user from '@/views/system/user';
// 菜单管理
import Module from '@/views/system/Module';
// 角色管理
import Role from '@/views/system/Role';

// 权限管理
import Permission from '@/views/system/Permission';
//个人中心
import Center from '@/views/system/Center'



// 启用路由
Vue.use(Router);

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {

    return originalPush.call(this, location).catch(err => err)
}


// 导出路由 
export default new Router({
    routes: [{
        path: '/',
        name: '',
        component: login,
        hidden: true,
        meta: {
            requireAuth: false
        }
    }, {
        path: '/login',
        name: '登录',
        component: login,
        hidden: true,
        meta: {
            requireAuth: false
        }
    }, {
        path: '/error',
        name: '403',
        component: error,
        hidden: true,
        meta: {
            requireAuth: false
        }
    }, {
        path: '/index',
        name: '首页',
        component: index,
        iconCls: 'el-icon-tickets',
        children: [{
            path: '/dashbord',
            name: '首页',
            component: Dashbord,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/basic/Goods',
            name: '商品管理',
            component: Goods,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/basic/Warehouse',
            name: '仓库管理',
            component: Warehouse,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/basic/Admin',
            name: '仓库人员管理',
            component: Admin,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/basic/Customer',
            name: '客户管理',
            component: Customer,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/basic/Supplier',
            name: '供应商管理',
            component: Supplier,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/basic/Warehousing',
            name: '入库管理',
            component: Warehousing,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/basic/Delivery',
            name: '出库管理',
            component: Delivery,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/system/user',
            name: '用户管理',
            component: user,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/system/Module',
            name: '菜单管理',
            component: Module,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/system/Role',
            name: '角色管理',
            component: Role,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/system/Permission',
            name: '权限管理',
            component: Permission,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/system/Center',
            name: '个人中心',
            component: Center,
            meta: {
                requireAuth: true
            }
        }]
    }]
})